﻿using Outils.Chaines;
#if !NUNIT
using Microsoft.VisualStudio.TestTools.UnitTesting;
#else
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute;
using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute;
using TestContext = NUnit.Framework.Text;
#endif
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace OutilsTests
{
    
    
    /// <summary>
    ///This is a test class for ChaineTest and is intended
    ///to contain all ChaineTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ChaineTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        /// Test de la méthode ValeurMonetaire
        ///</summary>
        [TestMethod()]
        public void ValeurMonetaireTest()
        {
            double unMontant = 1.230F;
            string expected="         1,23";
            string actual;
            actual = Chaine.ValeurMonetaire( unMontant );
            Assert.AreEqual(expected, actual, "ValeurMonetaire");
            
        }

        /// <summary>
        /// Test de la méthode TraitsDroit
        ///</summary>
        [TestMethod()]
        public void TraitsDroitTest()
        {
            string expected = "______________________________";

            string actual;
            actual = Chaine.TraitsDroit();
            Assert.AreEqual( expected, actual, "TraitsDroit" );
        
        }

        /// <summary>
        /// Test de la méthode Traits
        ///</summary>
        [TestMethod()]
        public void TraitsTest()
        {
            string expected = string.Empty; 
            string actual;
            actual = Chaine.Traits();
            Assert.AreEqual( expected, actual, "" );
            
        }

        /// <summary>
        /// Test de la méthode Tab
        ///</summary>
        [TestMethod()]
        public void TabTest()
        {
            short nombreTabulations = 1; 
            string expected = "    ";
            string actual;
            actual = Chaine.Tab( nombreTabulations );
            Assert.AreEqual( expected, actual, "TabTest" );
            
        }

        /// <summary>
        /// Test de la méthode SansBlancs
        ///</summary>
        [TestMethod()]
        public void SansBlancsTest()
        {
            string s = "Initialize to an appropriate value";
            string expected = "Initializetoanappropriatevalue";
            string actual;
            actual = Chaine.SansBlancs( s );
            Assert.AreEqual( expected, actual, "SansBlancs" ); 
        }

        /// <summary>
        /// Test de la méthode RetournePlurielouSingulier
        ///</summary>
        [TestMethod()]
        public void RetourneChainePlurielouSingulierTest()
        {
            int Valeur = 0; 
            string mot = string.Empty; 
            string separateur = string.Empty; 
            string expected = string.Empty; 
            string actual;
            actual = Chaine.RetourneChainePlurielouSingulier( Valeur, mot, separateur );
            Assert.AreEqual(expected, actual, "RetourneChainePlurielouSingulier");
            
        }

        /// <summary>
        /// Test de la méthode RemoveDiacritics
        ///</summary>
        [TestMethod()]
        public void RetireDiacriticsTest()
        {
            string inputString = string.Empty; 
            string expected = string.Empty; 
            string actual;
            actual = Chaine.RetireDiacritics( inputString );
            Assert.AreEqual( expected, actual, "RetireDiacritics" );
            
        }

        /// <summary>
        /// Test de la méthode QuoteForCsv
        ///</summary>
        [TestMethod()]
        public void QuoteForCsvTest()
        {
            string s = string.Empty; 
            string expected = string.Empty; 
            string actual;
            actual = Chaine.QuoteForCsv( s );
            Assert.AreEqual( expected, actual, "" );
            
        }

        /// <summary>
        /// Test de la méthode NumeroValide
        ///</summary>
        [TestMethod()]
        public void NumeroValideTest()
        {
            object _Numero = null; 
            int expected = 0; 
            int actual;
            actual = Chaine.NumeroValide( _Numero );
            Assert.AreEqual( expected, actual, "" );
            
        }

        /// <summary>
        /// Test de la méthode NettoieChaine
        ///</summary>
        [TestMethod()]
        public void NettoieChaineTest()
        {
            string strPattern = string.Empty; 
            string strChaine = string.Empty; 
            string expected = string.Empty; 
            string actual;
            actual = Chaine.NettoieChaine( strPattern, strChaine );
            Assert.AreEqual( expected, actual, "" );
            
        }


        /// <summary>
        /// Test de la méthode Majuscule
        ///</summary>
        [TestMethod()]
        public void MajusculeTest()
        {
            string _chaine = "test de mise en majuscules";
            string expected = "TEST DE MISE EN MAJUSCULES"; 
            string actual;
            actual = Chaine.RetourneChaineMajuscules( _chaine );
            Assert.AreEqual( expected, actual, "Majuscule" ); 

            //TODO : Test accents
        }

        /// <summary>
        /// Test de la méthode LimiteChaine
        ///</summary>
        [TestMethod()]
        public void LimiteChaineTest()
        {
            string p_Texte = "test";
            int p_Longueur = 2;
            string expected = "te";
            string actual;
            actual = Chaine.LimiteChaine( p_Texte, p_Longueur );
            Assert.AreEqual( expected, actual, "" );

            p_Texte = string.Empty;
            expected = "  ";

            actual = Chaine.LimiteChaine( p_Texte, p_Longueur );
            Assert.AreEqual( expected, actual, "LimiteChaine" );
        }

        /// <summary>
        /// Test de la méthode IntToString
        ///</summary>
        [TestMethod()]
        public void IntToStringTest()
        {
            int Valeur = 123456;
            string expected = "123456";
            string actual;
            actual = Chaine.IntToString( Valeur );
            Assert.AreEqual(expected, actual, "IntToString"); 
        }

        /// <summary>
        /// Test de la méthode HashString
        ///</summary>
        [TestMethod()]
        public void HashStringTest()
        {
            string stringToHash = "bob";
            string expected = "gbY32PzSxtpjWeaWMROhFw3nleS3JbhNHgtM/Z7FjOk="; 
            string actual;
            actual = Chaine.HashString( stringToHash );
            Assert.AreEqual( expected, actual, "HashString" ); 
        }

        /// <summary>
        /// Test de la méthode Gauche
        ///</summary>
        [TestMethod()]
        public void GaucheTest()
        {
            string p_Texte = "Initialize to an appropriate value";
            int p_Longueur = 10;  
            string expected = "Initialize";
            string actual;
            actual = Chaine.Gauche( p_Texte, p_Longueur );
            Assert.AreEqual( expected, actual, "Gauche" ); 
        }

        /// <summary>
        /// Test de la méthode FormatBytes
        ///</summary>
        [TestMethod()]
        public void FormatBytesTest()
        {
            byte[] data = null; 
            string expected = string.Empty; 
            string actual;
            actual = Chaine.FormatBytes( data );
            Assert.AreEqual( expected, actual, "" );
            
        }

        /// <summary>
        /// Test de la méthode Extrait
        ///</summary>
        [TestMethod()]
        public void ExtraitChaineTest()
        {
            string chaine = "Initialize to an appropriate value";
            int debut = 5; 
            int longueur = 10;
            string expected = "alize to a";
            string actual;
            actual = Chaine.ExtraitChaine(chaine, debut, longueur);
            Assert.AreEqual( expected, actual, "Extrait" ); 
        }

        /// <summary>
        /// Test de la méthode Droite
        ///</summary>
        [TestMethod()]
        public void DroiteTest()
        {
            string p_Texte = "Initialize to an appropriate value";
            int p_Longueur = 5;  
            string expected = "value";
            string actual;
            actual = Chaine.Droite( p_Texte, p_Longueur );
            Assert.AreEqual( expected, actual, "Droite" ); 
        }

     
        /// <summary>
        /// Test de la méthode ConvertirChaineSansAccent
        ///</summary>
        [TestMethod()]
        public void ConvertirChaineSansAccentTest()
        {
            string chaine = string.Empty; 
            string expected = string.Empty; 
            string actual;
            actual = Chaine.RetourneChaineSansAccent( chaine );
            Assert.AreEqual( expected, actual, "ConvertirChaineSansAccent" ); 
        }

        /// <summary>
        /// Test de la méthode ChaineValide
        ///</summary>
        [TestMethod()]
        public void ChaineValideTest()
        {
            object chaine = null; 
            string expected = string.Empty; 
            string actual;
            actual = Chaine.ChaineValide( chaine );
            Assert.AreEqual( expected, actual, "ChaineValide" ); 
        }

        /// <summary>
        /// Test de la méthode ChaineExpansee
        ///</summary>
        [TestMethod()]
        public void ChaineExpanseeTest()
        {
            string chaineCompressee = string.Empty; 
            string expected = string.Empty; 
            string actual;
            actual = Chaine.ChaineExpansee( chaineCompressee );
            Assert.AreEqual( expected, actual, "ChaineExpansee" ); 
        }

        /// <summary>
        /// Test de la méthode Blancs
        ///</summary>
        [TestMethod()]
        public void BlancsTest()
        {
            int p_Longueur = 0; 
            bool pbApplique = false; 
            string expected = string.Empty; 
            string actual;
            actual = Chaine.Blancs( p_Longueur, pbApplique );
            Assert.AreEqual( expected, actual, "Blancs" ); 
        }

        /// <summary>
        ///Test pour QuoteForCsv
        ///</summary>
        [TestMethod()]
        public void QuoteForCsvTest1()
        {
            string s = "Essai \"un, deux, trois\"";
            string expected = "\"Essai \"\"un, deux, trois\"\"\"";
            string actual;
            actual = Chaine.QuoteForCsv(s);
            Assert.AreEqual(expected, actual,"QuoteForCsvTest");
        }

        /// <summary>
        ///Test pour FormatBytes
        ///</summary>
        [TestMethod()]
        public void FormatBytesTest1()
        {
            byte[] donnees = null; // TODO : initialisez à une valeur appropriée
            string expected = string.Empty; // TODO : initialisez à une valeur appropriée
            string actual;
            actual = Chaine.FormatBytes(donnees);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Vérifiez l\'exactitude de cette méthode de test.");
        }

        /// <summary>
        ///Test pour EstIdentificateurUniqueGlobal
        ///</summary>
        [TestMethod()]
        public void EstIdentificateurUniqueGlobal_Guid_Vrai()
        {
            Guid guid = new Guid();
            string identificateurUniqueGlobal = guid.ToString();
            bool expected = true; 
            bool actual;
            actual = Chaine.EstIdentificateurUniqueGlobal(identificateurUniqueGlobal);
            Assert.AreEqual(expected, actual,"EstIdentificateurUniqueGlobal_Guid_Vrai");
        }

        /// <summary>
        ///Test pour EstIdentificateurUniqueGlobal
        ///</summary>
        [TestMethod()]
        public void EstIdentificateurUniqueGlobal_Divers_Faux()
        {
            string identificateurUniqueGlobal = "Divers";
            bool expected = false;
            bool actual;
            actual = Chaine.EstIdentificateurUniqueGlobal(identificateurUniqueGlobal);
            Assert.AreEqual(expected, actual, "EstIdentificateurUniqueGlobal_Divers_Faux");
        }
    }
}
